from basic.device.Android import Android
from airtest.core.api import *

class sharePage(Android):

    #我的
    myBtn = "com.cloudbae.lovenanning:id/tab4"
    # 我的页面
    myView = "com.cloudbae.lovenanning:id/my_item_container"
    # 分享弹窗
    pop = "com.cloudbae.lovenanning:id/cancel_share"
    weChat = "com.cloudbae.lovenanning:id/we_chat"
    weChat_friend = "com.cloudbae.lovenanning:id/we_chat_friend"
    sina = "com.cloudbae.lovenanning:id/sina"
    qq = "com.cloudbae.lovenanning:id/qq"
    # 关闭提示登录
    close_LoginFrame = "com.cloudbae.lovenanning:id/realNameFrame_close"
    # 微信登录页面文字
    wechatText = "com.tencent.mm:id/d67"
    wechatText = "android:id/text1"

    @classmethod
    def clickmyBtn(self):
        self.poco(self.myBtn).click()

    @classmethod
    def clickShare(self):
        sleep(1)
        closeHint = self.poco(self.close_LoginFrame)
        if closeHint.exists():
            closeHint.click()
        self.poco(self.myView).scroll(direction='vertical', percent=0.7, duration=2.0)
        self.poco(text='分享').click()



    @classmethod
    def shareCheck(self):
        if self.poco(self.pop).exists()!=True:
            return True
        else:
            return False
    # def sharePop(self):
    #     pop = self.poco(self.shareContent)
    #     if pop.exists() !=True:
    #         return True
    #     else:
    #         return False

    @classmethod
    def getShare(self):

        share1 = self.poco(self.weChat)
        share2 = self.poco(self.weChat_friend)
        share3 = self.poco(self.sina)
        share4 = self.poco(self.qq)

        listText=[]
        listText.append(share1.get_name())
        listText.append(share2.get_name())
        listText.append(share3.get_name())
        listText.append(share4.get_name())
        print("----------")
        print(len(listText))
        print("----------")
        print(listText)
        return listText

    @classmethod
    def clickWechat(self):
        self.poco(self.weChat).click()

    @classmethod
    def getWechatText(self):
        sleep(3)
        wechatText = self.poco(self.wechatText).get_text()
        print('微信登录页面：',wechatText)
        return wechatText

